function loginJS() {
	var username = document.getElementById("username").value;
	var password = document.getElementById("password").value;
	
	$.getJSON("/writeonproject/login?action=login&user=" + username + "&password=" + password, loginCallBack );
}

function loginCallBack(data) {
	if( data.loggedIn != null && data.loggedIn == "true") {
		window.location.reload();
	} else {
		alert("Your credentials are invalid or your account has not been activated yet!");
	}
}

function logoutJS() {
	$.getJSON("/writeonproject/login?action=logout", logoutCallBack);
}

function logoutCallBack(data) {
	window.location.reload();
}

function forgotpasswordJS() {
	var userid = document.forms["forgotpw"]["forgotpass"].value;
//	alert(userid);
	if( userid != null && userid != "" ) {
		$.getJSON("/writeonproject/login?action=forgotpassword&user=" + userid, passwordCallBack);
	}
}

function passwordCallBack(data) {
	if( data.error != null ) {
		alert(data.reason);
	}
}